from utils import xprimes

LIMIT = 1000000
OPT = 1000

primes = list(xprimes(LIMIT))
primeset = set(primes)

longest = 0
longest_sum = 0
for i in range(0, len(primes)/OPT):
    max_prime = 0
    prime_sum = 0
    length = 0
    for j, p in enumerate(primes[i:]):
        if prime_sum > LIMIT:
            break
        else:
            prime_sum += p
        if prime_sum in primeset:
            max_prime = prime_sum
            length = j+1
    if length > longest:
        longest = length
        longest_sum = max_prime

print longest_sum
